package 动态规划专项训练.动态规划训练2;

/**买卖股票的最佳时机 II
 * @author zx
 * @create 2022-04-08 11:31
 */
public class Num122 {
    public int maxProfit(int[] prices) {
        int res = 0;
        for(int i = 0;i < prices.length - 1;i++){
            if(prices[i + 1] - prices[i] > 0){
                res += prices[i + 1] - prices[i];
            }
        }
        return res;
    }
}
